home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 July / CHIP 2006-07.2.iso / program / web_gelistirme / easyphp1-7_setup.exe / {app} / phpmyadmin / left.php < prev    next >
Encoding:
PHP Script  |  2003-09-07  |  36.1 KB  |  794 lines

  1. <?php
  2. /* $Id: left.php,v 1.131 2003/07/25 13:59:47 garvinhicking Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. /**
  7.  * Gets the variables sent to this script, retains the db name that may have
  8.  * been defined as startup option and include a core library
  9.  */
  10. require('./libraries/grab_globals.lib.php');
  11. if (isset($lightm_db) && !empty($lightm_db)) {
  12. // no longer urlencoded because of html entities in the db name
  13. //    $db = urldecode($lightm_db);
  14.     $db = $lightm_db;
  15. }
  16.  
  17. if (!empty($db)) {
  18.     $db_start = $db;
  19. }
  20.  
  21.  
  22. /**
  23.  * Gets a core script and starts output buffering work
  24.  */
  25. require('./libraries/common.lib.php');
  26. require('./libraries/ob.lib.php');
  27. if ($cfg['OBGzip']) {
  28.     $ob_mode = PMA_outBufferModeGet();
  29.     if ($ob_mode) {
  30.         PMA_outBufferPre($ob_mode);
  31.     }
  32. }
  33.  
  34. PMA_checkParameters(array('hash'));
  35.  
  36. include('./libraries/bookmark.lib.php');
  37. require('./libraries/relation.lib.php');
  38. $cfgRelation = PMA_getRelationsParam();
  39.  
  40. function PMA_reduceNest($_table) {
  41.  
  42.     if ($GLOBALS['cfg']['LeftFrameTableLevel'] > 0) {
  43.         $max = $GLOBALS['cfg']['LeftFrameTableLevel'];
  44.         $temp_table = $_table;
  45.         $new_table = array();
  46.         $last_index = 0;
  47.         for ($ti = 0; $ti < $max; $ti++) {
  48.             if (isset($temp_table[$ti])) {
  49.                 $new_table[$ti] = $temp_table[$ti];
  50.                 unset($temp_table[$ti]);
  51.                 $last_index = $ti;
  52.             }
  53.         }
  54.  
  55.         $_table = $new_table;
  56.     }
  57.  
  58.     return $_table;
  59. }
  60.  
  61. function PMA_indent($spaces) {
  62.     $string = '';
  63.     for ($i = 0; $i <= $spaces; $i++) {
  64.         $string .= ' ';
  65.     }
  66.     
  67.     return $string;
  68. }
  69.  
  70. function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
  71.     $name = $key;
  72.     $id = eregi_replace('[^a-z0-9]*', '', $baseid . $keyhistory . $key) . $indent;
  73.  
  74.     $on_mouse = (($GLOBALS['cfg']['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
  75.  
  76.     $countarray = $val;
  77.     if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
  78.         $counter = count($countarray['pma_name']);
  79.     } else {
  80.         unset($countarray['pma_name']);
  81.         if (count($countarray) > 1) {
  82.             unset($countarray['pma_list_item']);
  83.         }
  84.         $counter = count($countarray);
  85.     }
  86.     
  87.     echo "\n";
  88.     echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Parent" class="parent"' . $on_mouse . '>' . "\n";
  89.     echo PMA_indent($indent * 6) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent - 1) * $indent_level) . '" height="9" alt="" /><a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '" onclick="if (capable) {expandBase(\'el' . $id . '\', true); return false} else {return true}">';
  90.     echo '<img name="imEx" id="el' . $id . 'Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
  91.     echo PMA_indent($indent * 6) . '<a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '" title="' . htmlspecialchars($name) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', false)}"><span class="heada">' . htmlspecialchars($name) . '<bdo dir="' . $GLOBALS['text_dir'] . '">  </bdo></span><span class="headaCnt">(' . $counter . ')</span></a></nobr>' . "\n";
  92.     echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeaderParent">' . "\n";
  93.     echo "\n";
  94.  
  95.     if ($childout) {
  96.         echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Child" class="child" ' . $on_mouse . '>' . "\n";
  97.     }
  98. }
  99.  
  100. function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
  101.     if ($firstGroup) {
  102.         PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
  103.         $indent++;
  104.     }
  105.     
  106.     while(list($key, $val) = each($tablestack)) {
  107.         if ($key != 'pma_name' && $key != 'pma_list_item') {
  108.             if ($headerOut) {
  109.                 PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
  110.             }
  111.     
  112.             if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
  113.                 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, false, ($indent + 1));
  114.             } else {
  115.                 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, true, ($indent + 1));
  116.             }
  117.     
  118.             if ($headerOut) {
  119.                 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeader">' . "\n";
  120.             }
  121.         }
  122.     }
  123.     
  124.     if ($firstGroup && $firstGroupClose) {
  125.         echo PMA_indent($indent * 4) . '</div><id class="PMA_nestedSetHeader2">' . "\n";
  126.     } elseif ($firstGroup) {
  127.         echo PMA_indent($indent * 4) . '<id spacer="div omitted" class="PMA_nestedSetHeader2">' . "\n";
  128.     }
  129. }
  130.  
  131. function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
  132.  
  133.     if ($keyhistory == '' && $key != '__protected__') {
  134.         $keyhistory = $key;
  135.     }
  136.     
  137.     $indent_level = 9;
  138.     
  139.     if (isset($tablestack)
  140.         && isset($tablestack['pma_name'])
  141.         && isset($tablestack['pma_list_item'])) {
  142.             
  143.         if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
  144.             PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+1), $indent_level, $headerOut, $key, false);
  145.             $divClose = true;
  146.             $extra_indent = 1;
  147.         } else {
  148.             PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
  149.             $divClose = false;
  150.             $extra_indent = 0;
  151.         }
  152.  
  153.         $on_mouse = (($GLOBALS['cfg']['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
  154.         
  155.         $loops = 0;
  156.         while(list($tkey, $tval) = each($tablestack['pma_name'])) {
  157.  
  158.             echo PMA_indent($indent * 5) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent+$extra_indent) * $indent_level) . '" height="9" alt="" />';
  159.             $items = explode("\n", $tablestack['pma_list_item'][$tkey]);
  160.             while(list($ikey, $ival) = each($items)) {
  161.                 echo "\n";
  162.                 echo PMA_indent(($indent * 5)) . $ival;
  163.             }
  164.             echo "\n";
  165.             
  166.             $loops++;
  167.         }
  168.         
  169.         if ($divClose) {
  170.             echo PMA_indent($indent * 5) . '</div><id space="putting omitted div" class="PMA_nestedSet2">';
  171.         }
  172.  
  173.     } elseif (is_array($tablestack)) {
  174.         PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )? ($indent-1) : ($indent + 1)), $indent_level, $headerOut,  (($key == '__protected__' && $indent == 1) || ($indent > 1) ? false : $key));
  175.     }
  176.     
  177.     return true;
  178. }
  179. /**
  180.  * Get the list and number of available databases.
  181.  * Skipped if no server selected: in this case no database should be displayed
  182.  * before the user choose among available ones at the welcome screen.
  183.  */
  184. if ($server > 0) {
  185.     PMA_availableDatabases(); // this function is defined in "common.lib.php"
  186. } else {
  187.     $num_dbs = 0;
  188. }
  189.  
  190.  
  191. // garvin: For re-usability, moved http-headers
  192. // to a seperate file. It can now be included by header.inc.php,
  193. // queryframe.php, querywindow.php.
  194.  
  195. include('./libraries/header_http.inc.php');
  196.  
  197. /**
  198.  * Displays the frame
  199.  */
  200. // Gets the font sizes to use
  201. PMA_setFontSizes();
  202. ?>
  203. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  204.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  205. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $available_languages[$lang][2]; ?>" lang="<?php echo $available_languages[$lang][2]; ?>" dir="<?php echo $text_dir; ?>">
  206.  
  207. <head>
  208.     <title>phpMyAdmin</title>
  209.     <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
  210.     <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain<?php echo $hash; ?>" />
  211.  
  212.     <script type="text/javascript" language="javascript">
  213.     <!--
  214. <?php
  215. if (isset($lightm_db) && !empty($lightm_db)) {
  216. ?>
  217.     window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./<?php echo $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&');?>');
  218. <?php 
  219. } elseif (isset($lightm_db)) {
  220. ?>
  221.     window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./main.php?<?php echo PMA_generate_common_url('', '', '&');?>');
  222. <?php 
  223. }
  224. ?>
  225.     //-->
  226.     </script>
  227.  
  228. <?php
  229. // Expandable/collapsible databases list is only used if there is more than one
  230. // database to display
  231. if (($num_dbs > 1 || !empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
  232.     echo "\n";
  233.     ?>
  234.     <!-- Collapsible tables list scripts -->
  235.     <script type="text/javascript" language="javascript">
  236.     <!--
  237.     var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
  238.                       && typeof(document.createElement) != 'undefined')
  239.                    ? 1 : 0;
  240.     var isIE4      = (typeof(document.all) != 'undefined'
  241.                       && parseInt(navigator.appVersion) >= 4)
  242.                    ? 1 : 0;
  243.     var isNS4      = (typeof(document.layers) != 'undefined')
  244.                    ? 1 : 0;
  245.     var capable    = (isDOM || isIE4 || isNS4)
  246.                    ? 1 : 0;
  247.     // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
  248.     if (capable) {
  249.         if (typeof(window.opera) != 'undefined') {
  250.             capable = 0;
  251.         }
  252.         else if (typeof(navigator.userAgent) != 'undefined') {
  253.             var browserName = ' ' + navigator.userAgent.toLowerCase();
  254.             if (browserName.indexOf('konqueror') > 0) {
  255.                 capable = 0;
  256.             }
  257.         } // end if... else if...
  258.     } // end if
  259.  
  260.     var isServer    = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
  261.  
  262.     document.writeln('<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&js_frame=left&js_capable=' + capable + '&js_isDOM=' + isDOM + '&js_isIE4=' + isIE4 + '" />');
  263.     //-->
  264.     </script>
  265.     <noscript>
  266.         <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
  267.     </noscript>
  268.  
  269.     <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
  270.     <?php
  271. } // end if ($num_dbs > 1)
  272.  
  273. else if ($num_dbs == 1) {
  274.     echo "\n";
  275.     ?>
  276.     <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
  277.     <?php
  278. } // end if ($num_dbs == 1)
  279.  
  280. else {
  281.     echo "\n";
  282.     ?>
  283.     <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&num_dbs=0" />
  284.     <?php
  285. } // end if ($num_dbs < 1)
  286.  
  287. echo "\n";
  288. ?>
  289. </head>
  290.  
  291. <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
  292.  
  293. <?php
  294. if ($cfg['LeftDisplayLogo']) {
  295.     ?>
  296.     <!-- phpMyAdmin logo -->
  297.     <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
  298.     <?php
  299. }
  300. echo "\n";
  301. if ($cfg['LeftDisplayServers']) {
  302. ?>
  303.         <form method="post" action="index.php" target="_parent">
  304.             <select name="server" onchange="this.form.submit();">
  305.     <?php
  306.     echo "\n";
  307.     reset($cfg['Servers']);
  308.     while (list($key, $val) = each($cfg['Servers'])) {
  309.         if (!empty($val['host'])) {
  310.             echo '                <option value="' . $key . '"';
  311.             if (!empty($server) && ($server == $key)) {
  312.                 echo ' selected="selected"';
  313.             }
  314.             echo '>';
  315.             if (!empty($val['verbose'])) {
  316.                 echo $val['verbose'];
  317.             } else {
  318.                 echo $val['host'];
  319.                 if (!empty($val['port'])) {
  320.                     echo ':' . $val['port'];
  321.                 }
  322.                 // loic1: skip this because it's not a so good idea to display
  323.                 //        sockets used to everybody
  324.                 // if (!empty($val['socket']) && PMA_PHP_INT_VERSION >= 30010) {
  325.                 //     echo ':' . $val['socket'];
  326.                 // }
  327.             }
  328.             // loic1: if 'only_db' is an array and there is more than one
  329.             //        value, displaying such informations may not be a so good
  330.             //        idea
  331.             if (!empty($val['only_db'])) {
  332.                 echo ' - ' . (is_array($val['only_db']) ? implode(', ', $val['only_db']) : $val['only_db']);
  333.             }
  334.             if (!empty($val['user']) && ($val['auth_type'] == 'config')) {
  335.                 echo '  (' . $val['user'] . ')';
  336.             }
  337.             echo ' </option>' . "\n";
  338.         } // end if (!empty($val['host']))
  339.     } // end while
  340.     ?>
  341.             </select>
  342.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  343.             <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
  344.             <noscript><input type="submit" value="<?php echo $strGo; ?>" /></noscript>
  345.         </form>
  346. <?php
  347. }
  348. echo "\n";
  349. ?>
  350.     <!-- Link to the welcome page -->
  351.     <div id="el1Parent" class="parent" style="margin-bottom: 5px">
  352.         <nobr><a class="item" href="main.php?<?php echo PMA_generate_common_url(); ?>"><span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
  353.     </div>
  354.  
  355.  
  356.     <!-- Databases and tables list -->
  357. <?php
  358. // Don't display expansible/collapsible database info if:
  359. // 1. $server == 0 (no server selected)
  360. //    This is the case when there are multiple servers and
  361. //    '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
  362. //    screen to appear with no database info displayed.
  363. // 2. there is only one database available (ie either only one database exists
  364. //    or $cfg['Servers']['only_db'] is defined and is not an array)
  365. //    In this case, the database should not be collapsible/expandable
  366. if ($num_dbs > 1) {
  367.  
  368.     // Light mode -> beginning of the select combo for databases
  369.     // Note: When javascript is active, the frameset will be changed from
  370.     // within left.php. With no JS (<noscript>) the whole frameset will
  371.     // be rebuilt with the new target frame.
  372.     if ($cfg['LeftFrameLight']) {
  373.         ?>
  374.         <script type="text/javascript" language="javascript">
  375.             document.writeln('<form method="post" action="left.php" name="left" target="nav">');
  376.         </script>
  377.         <noscript>
  378.             <form method="post" action="index.php" name="left" target="_parent">
  379.         </noscript>
  380.         <?php
  381.         echo PMA_generate_common_hidden_inputs();
  382.         echo '        <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
  383.         echo '        <select name="lightm_db" onchange="this.form.submit()">' . "\n";
  384.         echo '            <option value="">(' . $strDatabases . ') ...</option>' . "\n";
  385.         $table_list = '';
  386.         $table_list_header = '';
  387.         $db_name    = '';
  388.     }
  389.  
  390.     $selected_db = 0;
  391.  
  392.     // Gets the tables list per database
  393.     for ($i = 0; $i < $num_dbs; $i++) {
  394.         $db = $dblist[$i];
  395.         $j  = $i + 2;
  396.         if (!empty($db_start) && $db == $db_start) {
  397.             $selected_db = $j;
  398.         }
  399.         $tables              = @PMA_mysql_list_tables($db);
  400.         $num_tables          = ($tables) ? @mysql_numrows($tables) : 0;
  401.         $common_url_query    = PMA_generate_common_url($db);
  402.         if ($num_tables) {
  403.             $num_tables_disp = $num_tables;
  404.         } else {
  405.             $num_tables_disp = '-';
  406.         }
  407.  
  408.         // Get additional information about tables for tooltip
  409.         if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
  410.             && $num_tables
  411.             && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
  412.             $tooltip = array();
  413.             $tooltip_name = array();
  414.             $result  = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  415.             while ($tmp = PMA_mysql_fetch_array($result)) {
  416.                 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
  417.                 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
  418.  
  419.                 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  420.                                        . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  421.             } // end while
  422.         } // end if
  423.  
  424.         // garvin: Get comments from PMA comments table
  425.         $db_tooltip = '';
  426.         if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
  427.             $tmp_db_tooltip = PMA_getComments($db);
  428.             if (is_array($tmp_db_tooltip)) {
  429.                 $db_tooltip = implode(' ', $tmp_db_tooltip);
  430.             }
  431.         }
  432.  
  433.         // No light mode -> displays the expandible/collapsible db list
  434.         if ($cfg['LeftFrameLight'] == FALSE) {
  435.  
  436.             // Displays the database name
  437.             $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
  438.  
  439.             echo "\n";
  440.             echo '    <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
  441.  
  442.             if (!empty($num_tables)) {
  443.                 echo "\n";
  444.                 ?>
  445.         <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', true); return false} else {return true}">
  446.             <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
  447.                 <?php
  448.             } else {
  449.                 echo "\n";
  450.                 ?>
  451.         <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
  452.                 <?php
  453.             }
  454.             echo "\n";
  455.             ?>
  456.         <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" title="<?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db) : htmlspecialchars($db_tooltip)); ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
  457.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
  458.     </div>
  459.  
  460.     <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  461. <?php
  462.             // Displays the list of tables from the current database
  463.             $tablestack = array();
  464.             for ($t = 0; $t < $num_tables; $t++) {
  465.                 $table     = PMA_mysql_tablename($tables, $t);
  466.                 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  467.                            ? htmlspecialchars($tooltip_name[$table])
  468.                            : '';
  469.                 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  470.                            ? htmlspecialchars($tooltip[$table])
  471.                            : '';
  472.  
  473.                 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
  474.  
  475.                 $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
  476.                 $list_item .= '<img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
  477.                 $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  478.                 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
  479.                 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
  480.                 
  481.                 // garvin: Check whether to display nested sets
  482.                 if (!empty($cfg['LeftFrameTableSeparator'])) {
  483.                     $_table = explode($cfg['LeftFrameTableSeparator'],  str_replace('\'', '\\\'',$table));
  484.                     if (is_array($_table)) {
  485.                         reset($_table);
  486.                         while(list($key, $val) = each($_table)) {
  487.                             if ($val == '') {
  488.                                 $_table[$key] = '__protected__';
  489.                             }
  490.                         }
  491.  
  492.                         unset($_table[count($_table)-1]);
  493.                         $_table = PMA_reduceNest($_table);
  494.                         
  495.                         $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . str_replace('\'', '\\\'', $table) . '\';';
  496.                         $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . str_replace('\'', '\\\'', $list_item) . '\';';
  497.                         eval($eval_string);
  498.                     } else {
  499.                         $tablestack['__protected__']['pma_name'][] = $table;
  500.                         $tablestack['__protected__']['pma_list_item'][] = $list_item;
  501.                     }
  502.                 } else {
  503.                     $tablestack['__protected__']['pma_name'][] = $table;
  504.                     $tablestack['__protected__']['pma_list_item'][] = $list_item;
  505.                 }
  506.             } // end for $t (tables list)
  507.             
  508.             PMA_nestedSet($j, $tablestack);
  509.             ?>
  510.     </div>
  511.             <?php
  512.             echo "\n";
  513.  
  514.         }
  515.  
  516.         // Light mode -> displays the select combo with databases names and the
  517.         // list of tables contained in the current database
  518.         else {
  519.             echo "\n";
  520.  
  521.             // Builds the databases' names list
  522.             if (!empty($db_start) && $db == $db_start) {
  523.                 // Gets the list of tables from the current database
  524.                 for ($t = 0; $t < $num_tables; $t++) {
  525.                     $table      = PMA_mysql_tablename($tables, $t);
  526.                     $url_title  = (!empty($tooltip) && isset($tooltip[$table]))
  527.                                 ? htmlentities($tooltip[$table])
  528.                                 : '';
  529.                     $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  530.                                ? htmlentities($tooltip_name[$table])
  531.                                : '';
  532.  
  533.                     $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
  534.  
  535.                     $table_list .= '    <nobr><a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
  536.                     $table_list .= '              <img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  537.                     if (PMA_USR_BROWSER_AGENT == 'IE') {
  538.                         $table_list .= '          <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></span></nobr><br />' . "\n";
  539.                     } else {
  540.                         $table_list .= '          <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
  541.                     }
  542.                 } // end for $t (tables list)
  543.  
  544.                 if (!$table_list) {
  545.                     $table_list = '    <br /><br />' . "\n"
  546.                                 . '    <div>' . $strNoTablesFound . '</div>' . "\n";
  547.                 }
  548.                 $selected = ' selected="selected"';
  549.  
  550.                 $table_list_header .= '    <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
  551.                 $table_list_header .= '        <span class="heada"><b>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . '</b><bdo dir="' . $text_dir . '">  </bdo></span></a><br />' . "\n\n";
  552.             } else {
  553.                 $selected = '';
  554.             } // end if... else...
  555.  
  556.             if (!empty($num_tables)) {
  557.                 echo '            <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
  558.             } else {
  559.                 echo '            <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
  560.             } // end if... else...
  561.  
  562.         } // end if (light mode)
  563.  
  564.     } // end for $i (db list)
  565.  
  566.     // Light mode -> end of the select combo for databases and table list for
  567.     // the current database
  568.     if ($cfg['LeftFrameLight']) {
  569.         echo '        </select>' . "\n";
  570.         echo '        <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
  571.         echo '    </form>' . "\n";
  572.  
  573.         if (!$table_list) {
  574.             $table_list = '    <div>' . $strSelectADb . '</div>' . "\n";
  575.         }
  576.  
  577.         // Displays the current database name and the list of tables it
  578.         // contains
  579.         echo "\n" . '    <hr noshade="noshade" />' . "\n\n";
  580.         echo $table_list_header;
  581.         echo $table_list;
  582.         echo "\n" . '    <hr noshade="noshade" />' . "\n";
  583.     }
  584.  
  585.     // No light mode -> initialize some js variables for the
  586.     // expandible/collapsible stuff
  587.     else {
  588.         ?>
  589.  
  590.     <!-- Arrange collapsible/expandable db list at startup -->
  591.     <script type="text/javascript" language="javascript1.2">
  592.     <!--
  593.     if (isNS4) {
  594.       firstEl  = 'el1Parent';
  595.       firstInd = nsGetIndex(firstEl);
  596.       nsShowAll();
  597.       nsArrangeList();
  598.     }
  599.     var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  600.     //-->
  601.     </script>
  602.         <?php
  603.  
  604.     } // end if... else... (light mode)
  605.  
  606. } // end if ($server > 1)
  607.  
  608.  
  609. // Case where only one database has to be displayed
  610. else if ($num_dbs == 1) {
  611.     $db                  = $dblist[0];
  612.     $tables              = @PMA_mysql_list_tables($db);
  613.     $num_tables          = ($tables) ? @mysql_numrows($tables) : 0;
  614.     $common_url_query    = PMA_generate_common_url($db);
  615.     if ($num_tables) {
  616.         $num_tables_disp = $num_tables;
  617.     } else {
  618.         $num_tables_disp = '-';
  619.     }
  620.  
  621.     // Get additional infomation about tables for tooltip
  622.     if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
  623.         && $num_tables) {
  624.         $tooltip = array();
  625.         $tooltip_name = array();
  626.         $result  = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  627.         while ($tmp = PMA_mysql_fetch_array($result)) {
  628.                 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
  629.                 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
  630.  
  631.             $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  632.                                    . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  633.         } // end while
  634.     } // end if
  635.  
  636.     // garvin: Get comments from PMA comments table
  637.     $db_tooltip = '';
  638.     if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
  639.         $tmp_db_tooltip = PMA_getComments($db);
  640.         if (is_array($tmp_db_tooltip)) {
  641.             $db_tooltip = implode(' ', $tmp_db_tooltip);
  642.         }
  643.     }
  644.  
  645.  
  646.     // Displays the database name
  647.     if (!$cfg['LeftFrameLight']) {
  648.             $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
  649.  
  650.             echo "\n";
  651.             echo '    <div id="el2Parent" class="parent"' . $on_mouse . '>';
  652.  
  653.             if (!empty($num_tables)) {
  654.                 echo "\n";
  655.                 ?>
  656.         <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el2', true); return false} else {return true}">
  657.             <img name="imEx" id="el2Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
  658.                 <?php
  659.             } else {
  660.                 echo "\n";
  661.                 ?>
  662.         <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
  663.                 <?php
  664.             }
  665.             echo "\n";
  666.             ?>
  667.         <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" title="<?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db) : htmlspecialchars($db_tooltip)); ?>" onclick="if (capable) {expandBase('el2', false)}">
  668.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
  669.     </div>
  670.  
  671.     <div id="el2Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  672.     <?php
  673.     } else {
  674.         echo "\n";
  675.         ?>
  676.     <div id="el2Parent" class="parent">
  677.         <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
  678.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
  679.     </div>
  680.     <div id="el2Child" class="child" style="margin-bottom: 5px">
  681.         <?php
  682.     }
  683.  
  684.     // Displays the list of tables from the current database
  685.     $tablestack = array();
  686.     for ($j = 0; $j < $num_tables; $j++) {
  687.         $table     = PMA_mysql_tablename($tables, $j);
  688.         $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  689.                    ? htmlentities($tooltip_name[$table])
  690.                    : '';
  691.         $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  692.                    ? htmlentities($tooltip[$table])
  693.                    : '';
  694.         $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
  695.  
  696.         if ($cfg['LeftFrameLight']) {
  697.         echo "\n";
  698.         ?>
  699.         <nobr><a target="phpmain<?php echo $hash; ?>" href="sql.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . $url_title; ?>">
  700.                   <img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
  701.               <a class="tblItem" id="tbl_<?php echo md5($table); ?>" title="<?php echo $url_title; ?>" target="phpmain<?php echo $hash; ?>" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
  702.                   <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
  703.         <?php
  704.         } else {
  705.             $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
  706.             $list_item .= '<img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
  707.             $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  708.             $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
  709.             $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />';
  710.             
  711.             // garvin: Check whether to display nested sets
  712.             if (!empty($cfg['LeftFrameTableSeparator'])) {
  713.                 $_table = explode($cfg['LeftFrameTableSeparator'], $table);
  714.                 if (is_array($_table)) {
  715.                     reset($_table);
  716.                     while(list($key, $val) = each($_table)) {
  717.                         if ($val == '') {
  718.                             $_table[$key] = '__protected__';
  719.                         }
  720.                     }
  721.                     unset($_table[count($_table)-1]);
  722.                     $_table = PMA_reduceNest($_table);
  723.  
  724.                     $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . $table . '\';';
  725.                     $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . $list_item . '\';';
  726.                     eval($eval_string);
  727.                 } else {
  728.                     $tablestack['__protected__']['pma_name'][] = $table;
  729.                     $tablestack['__protected__']['pma_list_item'][] = $list_item;
  730.                 }
  731.             } else {
  732.                 $tablestack['__protected__']['pma_name'][] = $table;
  733.                 $tablestack['__protected__']['pma_list_item'][] = $list_item;
  734.             }
  735.         }
  736.     } // end for $j (tables list)
  737.  
  738.     if (!$cfg['LeftFrameLight']) {
  739.         PMA_nestedSet('1', $tablestack);
  740.         ?>
  741.     </div>
  742.     <!-- Arrange collapsible/expandable db list at startup -->
  743.     <script type="text/javascript" language="javascript1.2">
  744.     <!--
  745.     if (isNS4) {
  746.       firstEl  = 'el1Parent';
  747.       firstInd = nsGetIndex(firstEl);
  748.       nsShowAll();
  749.       nsArrangeList();
  750.     }
  751.     var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  752.     //-->
  753.     </script>
  754.         <?php
  755.     } else {
  756.         echo '    </div>';
  757.     }
  758.     
  759.     echo "\n";
  760. } // end if ($num_dbs == 1)
  761.  
  762.  
  763. // Case where no database has to be displayed
  764. else {
  765.     echo "\n";
  766.     echo '<p>' . $strNoDatabases . '</p>';
  767. } // end if ($num_dbs == 0)
  768. echo "\n";
  769. ?>
  770.  
  771. </body>
  772. </html>
  773.  
  774. <?php
  775. /**
  776.  * Close MySql connections
  777.  */
  778. if (isset($dbh) && $dbh) {
  779.     @mysql_close($dbh);
  780. }
  781. if (isset($userlink) && $userlink) {
  782.     @mysql_close($userlink);
  783. }
  784.  
  785.  
  786. /**
  787.  * Sends bufferized data
  788.  */
  789. if (isset($cfg['OBGzip']) && $cfg['OBGzip']
  790.     && isset($ob_mode) && $ob_mode) {
  791.      PMA_outBufferPost($ob_mode);
  792. }
  793. ?>
  794.